package com.base.cn.platform.os.service.manage.user.user;

import com.base.cn.platform.os.entity.user.user.CusUser;
import com.base.cn.platform.os.entity.user.user.UserCondition;
import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.manage.BaseService;
import com.github.pagehelper.PageInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 *  用户数据接口
 *
 * @author ll
 * @create 2018-04-09-19:05
 */
@FeignClient(value = BaseService.appName,configuration = FeignAuthConfig.class)
public interface CusUserService extends BaseService {

    /**
     * 分页搜索学员用户列表
     * @param user 用户条件
     * @param currentPage 分页
     * @param pageSize 查询数量
     * @return
     */
    @RequestMapping(contextPath + "/user/findUserListPage")
    PageInfo<CusUser> findUserListPage(@RequestBody UserCondition user,
                                              @RequestParam("currentPage") int currentPage,
                                              @RequestParam("pageSize") int pageSize);

    /**
     *  查询用户分页列表
     * @param user 查询条件
     * @return 用户数据列表
     */
    @RequestMapping(contextPath + "/user/queryUserListPage")
    Map<String, Object> queryUserListPage(@RequestBody Map<String, Object> user,
                                          @RequestParam("currentPage") Integer currentPage,
                                          @RequestParam("subjectData") boolean subjectData,
                                          @RequestParam("userAddresses") boolean userAddresses,
                                          @RequestParam("expRule") boolean expRule,
                                          @RequestParam("gradeConfig") boolean gradeConfig,
                                          @RequestParam("integral") boolean integral,
                                          @RequestParam("userMember") boolean userMember,
                                          @RequestParam("expAccount") boolean expAccount);

    /**
     * 多条件查询学员用户数据列表
     * @param condition 查询条件
     * @param subjectData 是否设置专业
     * @param userAddresses 是否设置收货地址
     * @param expRule 是否设置经验规则
     * @param gradeConfig 是否设置经验
     * @param integral 是否设置积分
     * @param userMember 是否设置会员数据
     * @param expAccount 是否设置账户数据
     * @return List<CusUser>
     */
    @RequestMapping(contextPath + "/user/queryUserList")
    List<Map<String,Object>> queryUserList(@RequestBody Map<String, Object> condition,
                                           @RequestParam(value = "subjectData", defaultValue = "false", required = false) boolean subjectData,
                                           @RequestParam(value = "userAddresses", defaultValue = "false", required = false) boolean userAddresses,
                                           @RequestParam(value = "expRule", defaultValue = "false", required = false) boolean expRule,
                                           @RequestParam(value = "gradeConfig", defaultValue = "false", required = false) boolean gradeConfig,
                                           @RequestParam(value = "integral", defaultValue = "false", required = false) boolean integral,
                                           @RequestParam(value = "userMember", defaultValue = "false", required = false) boolean userMember,
                                           @RequestParam(value = "expAccount", defaultValue = "false", required = false) boolean expAccount);

    /**
     * 添加用户
     * @param user
     * @param isAdminCreate 是不是后台创建（不包括批量导入）
     * @return
     */
    @RequestMapping(contextPath + "/user/saveUser")
    Map<String,Object> saveUser(@RequestBody Map<String, Object> user,
                                @RequestParam("isAdminCreate") boolean isAdminCreate, @RequestParam(value = "courseIds", required = false) String courseIds);

    /**
     * 修改用户状态
     * @param userId
     * @param status
     * @return
     */
    @RequestMapping(contextPath + "/user/updateCusUserStatus")
    Map<String,Object> updateCusUserStatus(@RequestParam("userIds") String userId,
                                           @RequestParam("status") Integer status);


    /**
     * 获取用户的学业数据
     * @param userId 用户ID
     * @return 学业信息
     */
    @RequestMapping(contextPath + "/user/getUserNaturalSubject")
    List<Map<String,Object>> getUserNaturalSubject(@RequestParam("userId") BigDecimal userId);

    /**
     * 获取用户的学业信息
     * @param userId 用户ID
     * @return 专业Map，key=subjectList基础专业，kye=attachSubjectList附加专业
     */
    @RequestMapping(contextPath + "/user/findUserAcademic")
    Map<String,List<Map<String,Object>>> findUserAcademic(@RequestParam("userId") BigDecimal userId);

    /**
     * 获取学员可以选择父级专业列表
     * @param userId 用户ID
     * @return List<Map<String,Object>>
     */
    @RequestMapping(contextPath + "/user/findUserSureSelectParentList")
    Map<String,Object> findUserSureSelectParentList(@RequestParam("userId") BigDecimal userId);

    /**
     * 查询用户可以选择的学业子级专业
     * @param userId 用户ID
     * @param parentIds 父级ID串，多个以“,”隔开
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/findUserSureSelectChildList")
    Map<String,Object> findUserSureSelectChildList(@RequestParam("userId") BigDecimal userId,
                                                   @RequestParam("parentIds") String parentIds);

    /**
     * 用户详情
     * @param userId
     * @return
     */
    @RequestMapping(contextPath + "/user/userInfo")
    Map<String,Object>  userInfo(@RequestParam("userId") BigDecimal userId,
                                 @RequestParam(value = "subjectData", required = false, defaultValue = "false") boolean subjectData,
                                 @RequestParam(value = "userAddresses", required = false, defaultValue = "false") boolean userAddresses,
                                 @RequestParam(value = "expRule", required = false, defaultValue = "false") boolean expRule,
                                 @RequestParam(value = "gradeConfig", required = false, defaultValue = "false") boolean gradeConfig,
                                 @RequestParam(value = "integral", required = false, defaultValue = "false") boolean integral,
                                 @RequestParam(value = "userMember", required = false, defaultValue = "false") boolean userMember,
                                 @RequestParam(value = "expAccount", required = false, defaultValue = "false") boolean expAccount);

    /**
     * 用户学习中心详情
     * @param condition
     * @return
     */
    @RequestMapping(contextPath + "/user/userStudyInfo")
    Map<String,Object>  userStudyInfo(@RequestBody UserCondition condition);

    /**
     * 保存用户头像
     * @param userId 用户ID
     * @param avatar 用户新头像
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/saveUserAvatar")
    Map<String,Object> saveUserAvatar(@RequestParam("userId") BigDecimal userId,
                                      @RequestParam("avatar") String avatar);
    /**
     * 根据用户Ids 搜索用户
     * @param userIds
     * @param subjectData 专业数据
     * @param userAddresses 地址
     * @param expRule 经验规则
     * @param gradeConfig 等级
     * @param integral 积分
     * @param userMember 会员
     * @param expAccount 经验
     * @return
     */
    @RequestMapping(contextPath + "/user/queryCusUserMapByUserIds")
    Map<BigDecimal,Map<String,Object>> queryCusUserMapByUserIds(@RequestParam("userIds") String userIds,
                                                                @RequestParam("subjectData") boolean subjectData,
                                                                @RequestParam("userAddresses") boolean userAddresses,
                                                                @RequestParam("expRule") boolean expRule,
                                                                @RequestParam("gradeConfig") boolean gradeConfig,
                                                                @RequestParam("integral") boolean integral,
                                                                @RequestParam("userMember") boolean userMember,
                                                                @RequestParam("expAccount") boolean expAccount);

    /**
     * 根据手机搜索用户
     * @param mobile
     * @return
     */
    @RequestMapping(contextPath + "/user/queryUserMobile")
    Map<String,Object> queryUserMobile(@RequestParam("mobile") String mobile);

    /**
     * 后台批量导入专用
     * @param users
     * @return
     */
    @RequestMapping(contextPath+"/user/createBatchUser") //保存用户数据
   void createUser(@RequestBody List<Map<String, Object>> users);
    /**
     * 根据邮箱搜索用户
     * @param email
     * @return
     */
    @RequestMapping(contextPath + "/user/queryUserEmail")
    Map<String,Object> queryUserEmail(@RequestParam("email") String email);

    /**
     * 根据登录账号搜索用户
     * @param loginAccount
     * @return
     */
    @RequestMapping(contextPath + "/user/queryUserLoginAccount")
    Map<String,Object> queryUserLoginAccount(@RequestParam("loginAccount") String loginAccount);

    /**
     * 通过UUID获取用户对象
     * @param uuid IOS的手机串号
     * @return 用户对象
     */
    @RequestMapping(contextPath + "/user/queryUserByUUID")
    Map<String,Object> queryUserByUUID(@RequestParam("uuid") String uuid);
    /**
     * 通过手机号码去查询用户，如果没有的话，创建用户  (仅供分销系统使用)
     * @param mobile
     * @return
     */
    @RequestMapping(contextPath + "/user/queryUserOrSaveUserByMobile")
    Map<String, Object> queryUserOrSaveUserByMobile(@RequestParam("mobile") String mobile);

    /**
     * 重置密码
     *
     * @param userId
     * @return
     */
    @RequestMapping(contextPath + "/user/resetPassword")
    Map<String, Object> resetPassword(@RequestParam("userId") BigDecimal userId,
                                      @RequestParam("rPassword") String rPassword);


    /**
     * 学员登录
     * @param user    用户属性对象
     * @param client  登录终端（PC、MOBILE、APP）
     * @param imageCode 是否有图片验证码
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/user/userLogin")
    Map<String, Object> userLogin(@RequestBody Map<String, Object> user,
                                  @RequestParam("client") String client,
                                  @RequestParam("imageCode") boolean imageCode);

    /**
     * 修改用户选择的专业
     * @param userId 用户ID
     * @param naturalSubjectIds 用户选择专业ID
     * @return CusUser
     */
    @RequestMapping(contextPath + "/user/updateUserNaturalSubjectIds")
    Map<String,Object> updateUserNaturalSubjectIds(@RequestParam("userId") BigDecimal userId,
                                                   @RequestParam("naturalSubjectIds") String naturalSubjectIds);

    /**
     * 修改用户的附加专业
     * @param userId     用户ID
     * @param subjectIds 专业ID串
     */
    @RequestMapping(contextPath + "/user/updateUserAttachSubjectIds")
    void updateUserAttachSubjectIds(@RequestParam("userId") BigDecimal userId,
                                    @RequestParam("subjectIds") String subjectIds);

    /**
     * 修改用户基本信息 API
     *
     * @param user 用户属性对象
     */
    @RequestMapping(contextPath + "/user/updateUser")
    Map<String, Object> updateUser(@RequestBody Map<String, Object> user);

    /**
     * 修改用户的问题数量
     * @param userId 用户ID
     */
    @RequestMapping(contextPath + "/user/updateUserNumberOfStatistics")
    void updateUserNumberOfStatistics(@RequestParam("userId") BigDecimal userId,
                                      @RequestParam("property") String property,
                                      @RequestParam("increase") Integer increase);

    /**
     * 修改用户密码
     *
     * @param userId     用户ID
     * @param nowPwd     用户原密码
     * @param newPwd     新密码
     * @param confirmPwd 确认密码
     */
    @RequestMapping(contextPath + "/user/updateUserPwd")
    Map<String,Object> updateUserPwd(@RequestParam("userId") BigDecimal userId,
                                     @RequestParam("nowPwd") String nowPwd,
                                     @RequestParam("newPwd") String newPwd,
                                     @RequestParam("confirmPwd") String confirmPwd,
                                     @RequestParam("sign") String sign);

    /**
     * 获取用户的附加专业数据
     * @param userId 用户ID
     * @return List<Map<String,Object>>
     */
    @RequestMapping(contextPath + "/user/findUserSubjectData")
    List<Map<String,Object>> findUserSubjectData(@RequestParam("userId") BigDecimal userId);

    /**
     * 修改最后获取作业的时间
     * @param userId
     * @param lastWorkTime
     * @return
     */
    @RequestMapping(contextPath + "/user/updateUserLastWorkTime")
    Map<String,Object> updateUserLastWorkTime(@RequestParam("userId") BigDecimal userId,
                                              @RequestParam("lastWorkTime") String lastWorkTime);

    /**
     * 检验手机号是否已存在于用户中
     * @param mobileList 手机列表
     * @return Map<String, Object>
     */
    @RequestMapping(contextPath + "/user/validateUserMobile")
    Map<String, Object> validateUserMobile(@RequestParam("mobileList") List<String> mobileList);

    /**
     * 根据手机号批量创建用户
     * @param mobileList 手机号
     * @return Map<String, Object>
     */
    @RequestMapping(contextPath + "/user/createUserByMobileList")
    Map<String, Object> createUserByMobileList(@RequestParam("mobileList") List<String> mobileList);

    /**
     * 更改用戶购买状态
     * @param userId 用户id
     */
    @RequestMapping(contextPath + "/user/updateUserBuyCourse")
    void updateUserBuyCourse(@RequestParam("userId") BigDecimal userId);

    /**
     * 查询用户考试可以选择的专业
     * @param userId 用户ID
     * @return 专业列表
     */
    @RequestMapping(contextPath + "/user/findUserExamSelectSubjectList")
    List<Map<String,Object>> findUserExamSelectSubjectList(@RequestParam("userId") BigDecimal userId);

    /**
     * 获取用户的所有的专业（基础专业和附加专业）
     * @param userId 用户ID
     * @return List<SysSubject>
     */
    @RequestMapping(contextPath + "/user/findAllUserSubjectList")
    List<Map<String,Object>> findAllUserSubjectList(@RequestParam("userId") BigDecimal userId);

    /**
     * 验证账号是否存在
     * @param account 用户ID
     * @return
     */
    @RequestMapping(contextPath + "/user/verifyAccount")
    Map<String,Object> verifyAccount(@RequestParam("account") String account);

    /**
     * 获取用户的所有专业ID串
     * @param userId 用户ID
     * @return  String
     */
    @RequestMapping(contextPath + "/user/findUserAllSubjectIds")
    String findUserAllSubjectIds(@RequestParam("userId") BigDecimal userId);

    /**
     * 执行导入用户文件
     * @param file 试题文件
     * @param sysUserId 创建的系统用户ID
     * @return Map<String, Object>
     */
    @RequestMapping(value = contextPath + "/user/importUser", method = {RequestMethod.POST}, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Map<String,Object> importUser(@RequestPart(value = "file") MultipartFile file,
                                  @RequestParam("sysUserId") BigDecimal sysUserId);


      /* 根据某一字段拼接的字符串查询
     * @param field
     * @param valueStr
     * @return
             */
    @RequestMapping(contextPath + "/user/queryUserByFieldValueStr")
    List<Map<String,Object>> queryUserByFieldValueStr(@RequestParam("field") String field, @RequestParam("valueStr") String valueStr);


    /**
     * 赠送商品
     * @param map
     * @return
     */
    @RequestMapping(contextPath+"/user/creatGifts")
    String creatGifts(@RequestBody Map map);

    /**
     * 创建excel导入学员
     * @param userMap
     * @return
     */
    @RequestMapping(contextPath + "/user/createExcelUser")
    Map<String,Object> createExcelUser(@RequestBody Map<String, Object> userMap);

    /**
     * 查询学员部分时长的统计
     * @param params
     * @return
     */
    @RequestMapping(contextPath +"/user/learningNumerical")
    @ResponseBody
     Map<String, Object> learningNumerical( @RequestBody Map params );}




